﻿using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Data;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class TFWI09
    {
        public TFWI09()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_STOCKM();
            this.DataContext = MV;
            InitializeComponent();

        } 
        public override void OnMKEYChg(DataRowView dwMKey)
        {
            if (dwMKey == null)
                return;
            string ART, VAR, FARBE, SPPART, ZWPART, FBPART, LO, LB, MDATE;
            DataTable tb;
            ART = dwMKey["ART"].ToString();
            VAR = dwMKey["VAR"].ToString();
            FARBE = dwMKey["FARBE"].ToString();
            LO = dwMKey["LO"].ToString();
            LB = dwMKey["LB"].ToString();
            SPPART = dwMKey["SPPART"].ToString();
            ZWPART = dwMKey["ZWPART"].ToString();
            FBPART = dwMKey["FBPART"].ToString();
            MDATE = dwMKey["MDATE"].ToString();
            string filter = "ART='" + ART + "' AND VAR='" + VAR + "' AND FARBE='" + FARBE + "' AND LO='" + LO + "' AND LB='" + LB + "' AND MDATE='" + MDATE + "'";

            if (vwMaster.View != null)
            {
                vwMaster.View.MoveCurrentToFirst();
            }
        }
        public void FilterMaster_Click(object sender, RoutedEventArgs e)
        {
            string filter = "ART LIKE '%" + ART.Trim() + "%' AND FARBE LIKE '" + FARBE.Trim() + "%' AND FINISH LIKE '%" + FINISH.Trim() + "%'";
            cvMaster.CustomFilter = filter;
        }
        public void FilterMasterClear_Click(object sender, RoutedEventArgs e)
        {

            cvMaster.CustomFilter = null;
        }
        public override void NewCommand(object sender, RoutedEventArgs e)
        {
            TMV.RefreshMWI(SYEAR + SMOTH, DTSTART, DTEND, LO, LB);
            Tracer.Info("", "已经更新完成");
            base.NewCommand(sender, e);  
        }

        public override void QueryCommand(object sender, RoutedEventArgs e)
        { 
            TMV.LoadMStock(MDATE, DTSTART, DTEND, LO, LB);

            vwMaster.View.MoveCurrentToFirst();
            base.QueryCommand(sender, e); 
        }

        private void PrintCommand(object sender, RoutedEventArgs e)
        {

        }

    }
}
